# Maintainer: David Runge <dvzrv@archlinux.org>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - !distcc, build checks for clang first

pkgname=roc-toolkit
pkgver=0.4.0
pkgrel=1
pkgdesc="Real-time audio streaming over the network"
arch=(x86_64)
url="https://github.com/roc-streaming/roc-toolkit/"
license=(
  CC0-1.0
  MPL-2.0
)
depends=(
  glibc
  gcc-libs
  libunwind
  libuv
  openssl
)
makedepends=(
  alsa-lib
  cpputest
  gengetopt
  libpulse
  openfec
  ragel
  scons
  sox
  speexdsp
)
options=(!distcc)
optdepends=(
  'libpulse: for roc-conv, roc-receive and roc-send'
  'sox: for roc-conv, roc-receive and roc-send'
)
provides=(libroc.so)
source=($url/archive/v$pkgver/$pkgname-v$pkgver.tar.gz)
sha512sums=('51763287ee825b6617273ededd9e77560f4223b8ba4a577855c3225908e848895a4f925163862cf6d19a8215245ec26f33d07d6cb80c51768d37eaa06ac02063')
b2sums=('2ffcf6b1ca50fcae09c7aaa27939e23428feb21f330d578d731e494c62aa088c7e00de3b1a1b488d1bb13ffcc979fede1fc2726e2293a383a87174a4480e8aec')

build() {
  local scons_options=(
    --prefix=/usr
    --libdir=/usr/lib
    --enable-tests
    --enable-examples
  )

  cd $pkgname-$pkgver
  scons "${scons_options[@]}"
}

check() {
  local scons_options=(
    --prefix=/usr
    --libdir=/usr/lib
    --enable-tests
    --enable-examples
  )

  cd $pkgname-$pkgver
  scons test "${scons_options[@]}"
}

package() {
  local scons_options=(
    --prefix=/usr
    --libdir=/usr/lib
  )
  depends+=(
    openfec libopenfec.so
    speexdsp libspeexdsp.so
  )

  cd $pkgname-$pkgver
  scons DESTDIR="$pkgdir/" "${scons_options[@]}" install

  install -vDm 644 3rdparty/hedley/COPYING -t "$pkgdir/usr/share/licenses/$pkgname/hedley.COPYING"
}
